<template>
	<view class="basic_container">
		<view class="item">
			<text>头像</text>
			<img src="https://www.xdyy100.com/wholesale/files/mp/static/setting/img.png">
		</view>
		<view class="item">
			<text>用户名</text>
			<text>{{ name }}</text>
		</view>
		<view class="item">
			<text>企业名称</text>
			<text>{{ purchaserName }}</text>
		</view>
		<view class="item">
			<text>联系电话</text>
			<text>{{ username }}</text>
		</view>

		<view class="logOut" @click="logOut"> 退出登录 </view>

	</view>
</template>

<script>
	import jwtDecode from 'jwt-decode'

	export default {
		data() {
			return {
				userAvatar: '',
				name: '',
				purchaserName: '',
				username: '',
			}
		},
		onShow() {
			let a = JSON.parse(jwtDecode(uni.getStorageSync('token')).userContext.replace('\\', ''))
			this.userAvatar = a.face
			this.name = a.name
			this.purchaserName = a.purchaserName
			this.username = a.username
		},
		methods: {
			logOut() {
				uni.removeStorageSync('token')
				uni.switchTab({
					url: '/pages/index/index',
					success: (res) => {
						uni.$emit('update', '更新首页')
						// 	let page = getCurrentPages().pop();
						// 	if (page == undefined || page == null) return;
						// 	page.onLoad()
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.basic_container {
		background: #f9f9f9;
		min-height: 100vh;
		padding-top: 20rpx;
	}

	.item {
		border-bottom: 1px solid #f9f9f9;
		padding: 40rpx 50rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		background: #fff;

		text {
			max-width: 70%;
		}
	}

	img {
		width: 117.36rpx;
		height: 117.36rpx;
	}

	.logOut {
		width: 80%;
		font-size: 30rpx;
		padding: 20rpx;
		background: #fff;
		text-align: center;
		margin: 0 auto;
		margin-top: 250rpx;
		border-radius: 50rpx;
	}
</style>